from cryptography.fernet import Fernet

def encrypt_model(model_params):
    """
    加密模型参数
    :param model_params: 模型参数
    :return: 加密后的参数
    """
    key = Fernet.generate_key()
    cipher_suite = Fernet(key)
    encrypted_params = cipher_suite.encrypt(model_params)
    return encrypted_params, key

# 示例
model_params = b"model_weights"
encrypted_params, key = encrypt_model(model_params)
print(f"Encrypted params: {encrypted_params}")